﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Payment : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login"] != null)
        {
            User user = Session["login"] as User;
            if (user.UserName == null)
            {
                Response.Redirect("Home.aspx");
            }
            Session["UserId"] = (Session["login"] as User).UserId;
        }
        else 
        {
            Response.Redirect("Home.aspx");
        }
    }
    protected void Button2_Command(object sender, CommandEventArgs e)
    {
        BillBll bbll = new BillBll();
        Bill bll = bbll.getBillById(Convert.ToInt32(e.CommandName));
        bll.IsPaid = true;
        bbll.updateBillPaidById(bll);
        Response.Redirect(Request.Url.AbsoluteUri);
    }
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        Button b = e.Item.FindControl("Button2") as Button;
        b.CommandName = DataBinder.Eval(e.Item.DataItem, "BillId").ToString();
    }
}